<?php defined('InShopNC') or exit('Access Invalid!');?>

<div class="tabmenu">
  <?php include template('layout/submenu');?>
</div>
<table class="ncsc-default-table">
  <?php if(!empty($output['list']) && is_array($output['list'])){?>
  <thead>
    <tr>
      <th class="w20">&nbsp;</th>
      <th class="tl w200">活动标题</th>
      <th class="tl">活动说明</th>
      <th class="w150">报名时间</th>
      <th class="w150">活动时间</th>
      <th class="w90">活动状态</th>
      <th class="w90">操作</th>
    </tr>
  </thead>
  <tbody>
    <?php foreach($output['list'] as $k => $v){?>
    <tr>
      <td></td>
      <td class="tl">
        <?php if($v['marketing_activity_apply_end_date'] > time()):?>
            <a target="_blank" href="<?=$v['details_url']?>"><?=$v['marketing_activity_title']?></a>
        <?php else:?>
            <a target="_blank" href="javascript:;"><?=$v['marketing_activity_title']?></a>
        <?php endif;?>
      </td>
      <td class="tl click_details" marketing_activity_id = "<?=$v['marketing_activity_id']?>" if_show_details = "<?=($v['marketing_activity_apply_end_date'] > time()) ? 'true' : 'false'?>">点击查看详情</td>
      <td class="goods-time"><?=$v['marketing_activity_apply_date']?></td>
      <td class="goods-time"><?=$v['marketing_activity_date']?></td>
      <td class="goods-time"><?=$v['marketing_activity_state_text']?></td>
      <td class="nscs-table-handle">
        <span>
          <?php if(isset($v['apply_sum']) && ($v['apply_sum'] > 0)):?>  <!-- 是否存在报名信息 -->
            <a id="a_<?=$v['marketing_activity_id']?>" href="<?=$v['details_url']?>"  class="btn-mint">
              <p>报名列表</p>
            </a>
          <?php else:?>
            <?php if($v['marketing_activity_apply_start_date'] > time()){?> <!-- 是否还能报名 -->
              <a href="javascript:;" class="btn-mint"><p>活动未开始</p></a>
            <?php }elseif($v['marketing_activity_apply_end_date'] > time()){?> <!-- 是否还能报名 -->
              <a id="a_<?=$v['marketing_activity_id']?>" href="<?=$v['details_url']?>"  class="btn-mint">
                <i class="icon-edit"></i>
                <p><?php echo $lang['store_activity_join'];?></p>
              </a>
            <?php }else{?>
              <a href="javascript:;" class="btn-mint"><p>不可报名</p></a>
            <?php }?>
          <?php endif;?>
        </span>
      </td>
    </tr>
    <?php } } else { ?>
    <tr>
      <td colspan="20" class="norecord"><div class="warning-option"><i class="icon-warning-sign"></i><span><?php echo $lang['no_record'];?></span></div></td>
    </tr>
    <?php } ?>
  </tbody>
  <tfoot>
    <?php if(!empty($output['list']) && is_array($output['list'])){?>
    <tr>
      <td colspan="20"><div class="pagination"><?php echo $output['show_page'];?></div></td>
    </tr>
    <?php }?>
  </tfoot>
</table>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/layer/layer.js"></script>
<script type="text/javascript">
    $(document).ready(function(){

        $('.click_details').on('click', function() {
            var if_show_details = $(this).attr('if_show_details');
            if (if_show_details !== 'true') {
              layer.msg('报名时间已经结束，活动说明暂停展示');
              return false;
            }
            var marketing_activity_id = $(this).attr('marketing_activity_id');
            if (typeof(marketing_activity_id) == 'undefined') {
              layer.msg('数据错误');
              return false;
            }
            var index = layer.load(2, {shade: false}); //0代表加载的风格，支持0-2
            $.ajax({
                url : "<?=urlShop('store_marketing_activity', 'get_activity_details')?>",
                type : "get",
                data : {marketing_activity_id:marketing_activity_id},
                error:function(data){
                    layer.msg('未知错误！', {icon: 5});
                    layer.close(index);
                },
                success:function(data){
                    layer.open({
                      type: 1,
                      title: '活动说明',
                      area: ['780px', '960px'], //宽高
                      content: data
                    });
                    layer.close(index);
                }
            });
        });

    });
</script>
